<template>
    <SysDialog draggable :title="dialog.title" :visible="dialog.visible" :width="dialog.width" :height="dialog.height"
        @onClose="onClose" @onConfirm="confirm">
        <template v-slot:content>
            <!-- 内容组件 -->
            <el-form :model="dialogModel" ref="addTaskForm" :rules="rules" label-width="120px" size="default">
                <el-form-item prop="versions" label="请输入版本号">
                    <el-input v-model="dialogModel.version"></el-input>
                </el-form-item>
            </el-form>
        </template>
    </SysDialog>
</template>
  
<script setup lang='ts'>
import { ref } from "vue";
import SysDialog from "@/components/SysDialog.vue";
import { ElForm } from "element-plus";
import useDialog from "@/hooks/useDialog";
import useInstance from "@/hooks/useInstance";
import { EditType, Title } from "@/type/BaseEnum";
import editVersionModel from "@/composables/02Review/01ProjectMan/EditVersion";
const addTaskForm = ref<InstanceType<typeof ElForm>>();
const { dialogModel, rules } = editVersionModel();
const emit = defineEmits(["save"]);
// 使用
const { dialog, onClose, onShow } = useDialog();
const { global, proxy } = useInstance();
// 父级数据

const confirm = () => {
    addTaskForm.value?.validate((isOk) => {
        if (isOk) {
            emit("save", dialogModel);
            onClose();
        }
    });
};
const show = (type: string, row?: any) => {
    console.log("show");
    dialog.width = 650;
    dialog.height = 50;
    dialog.title = EditType.EDIT ? Title.EDIT : Title.EDIT;
    onShow();
    global.$resetForm(addTaskForm.value, dialogModel);
    console.log(row)
    dialogModel.id = row.id;
};
defineExpose({
    show,
});
</script>
<style scoped lang='scss'></style>